package com.struts2.example.action;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.opensymphony.xwork2.ActionSupport;
import com.struts2.example.model.*;

public class Register extends ActionSupport {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String username;
	private String password;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	RegisterDao dao = new RegisterDao();
	
	//  
	 public String execute_rs()
	 {
		int i = RegisterDao.save(this);
		if(i >0)
			return "success";
		else 
			return "erro";
	 }
	// 
	
	 public String execute_checklogin() //throws SQLException
	 {
		 int i = 0;
		 try {
			 ResultSet resul = RegisterDao.check_login(this);
			 while(resul.next())
			 {
				 ++i;
			 }
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		 
		 if(i> 0)
			 return "success";
		 else
			 return "erro";
		 
		 
			 
	 }
	
	 
	
	
	
	

}
